package dabs.engine;
import dabs.engine.messaging.*;

public class Environment implements Updatable
{
	GameEngine engine;
	PostOffice postOffice;
	
	int generationSpeed = 0;
	int time = 0; // used for generating events
	
	void setGenerationSpeed(int spd) { this.generationSpeed = spd; }
	int getGenerationSpeed() { return generationSpeed; }
	
	public Environment(GameEngine engine, int speed) {
		setGenerationSpeed(speed);
		this.engine = engine;
		postOffice = engine.getPostOffice();
	}

	public void tick() {
		time++;
		// every 'generationSpeed' we create a new notification and pass it to the post office
		if (time > generationSpeed) {
			postOffice.handleNotification( new Notification("Environment", 
						"Event has been generated!"));
			time = 0;
			// TODO engine.getOperatorSoftware().handleModifier(new TemporaryDisable(3));
			//Temporary testing - passes a message to reactor1, BAD CODE,
			((Reactor) engine.powerPlant.getComponents().get(0)).handleModifier(new TemporaryDisable(10));
		}
	}

}
